package com.ljfiction.book.Dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;

import com.ljfiction.book.R;

/**
 * Created by Android on 2018/2/2.
 */

public class SubcritTishiDialog {
    private Dialog mDialog;
    private RelativeLayout relativeLayout;

    public SubcritTishiDialog(final Context context) {
        mDialog = new Dialog(context, R.style.AppTheme2);
        Window window = mDialog.getWindow();
        WindowManager.LayoutParams wl = window.getAttributes();
        wl.x = 0;
        wl.y = 0;
        window.setAttributes(wl);
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        window.setGravity(Gravity.RIGHT|Gravity.BOTTOM);
        window.setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
        mDialog.setContentView(R.layout.subcrittishi);
        mDialog.setCanceledOnTouchOutside(true);
        mDialog.show();
        mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialogInterface) {
                new TucaoTishiDialog(context);
            }
        });
       relativeLayout= mDialog.findViewById(R.id.subcritdialogxml);
        relativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mDialog!=null){
                    mDialog.dismiss();
                }
            }
        });
    }
}
